package edu.rit.teamrocket.model;

import java.io.Serializable;
import java.util.ArrayList;


public class DailyLog implements Serializable
{
	final int DEFAULT_CALORIE_LIMIT = 1800;
	final int DEFAULT_WEIGHT_LIMIT = 160;
	private ArrayList<FoodItem> foods;
	private int calorieLimit;
	private int weightLimit;
	private double weight;
	private Date date;
	
	
	public DailyLog(double weight, Date date) 
	{	
		this.calorieLimit = this.DEFAULT_CALORIE_LIMIT;
		this.weightLimit = this.DEFAULT_WEIGHT_LIMIT;
		this.weight = weight;
		this.date = date;
	}
	
	public void addToLog(Entry entry, int numberOfUnits) 
	{
		foods.add(new FoodItem(entry, numberOfUnits));
	}
	
	
	public void removeFromLog(FoodItem item) 
	{
		if (foods.contains(item))
			foods.remove(item);
	}
	
	public void setCalorieLimit(int calorieLimit) 
	{	
		this.calorieLimit = calorieLimit;
	}
	
	public void setWeightLimit(int weightLimit)
	{	
		this.weightLimit = weightLimit;
	}
	
	public int getCalorieLimit() 
	{	
		return this.calorieLimit;
	}
	
	public int getWeightLimit()
	{	
		return this.weightLimit;
	}
	
	public int getTotalCalories() 
	{	
		int totalCalories = 0;
		
		for (FoodItem item : foods)
		{
			totalCalories += item.getEntry().getCalories();
		}
		return totalCalories;
	}
	
	public double getWeight() 
	{
		return this.weight;
	}
	
	public Date getDate() 
	{
		return this.date;
	}
}
